import { createRouter, createWebHistory } from 'vue-router'
import { beforeEach } from './premission'
// import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  // 添加路由
  // 定义需要嵌套的页面文件
  routes: [
    // 前台(顶部导航/内容区)
    {
      path: '/frontend',
      name: 'Frontend',
      component: () => import('../views/frontend/Layout_View.vue'),
      children: [
        {
          path: 'blogs',
          name: 'FrontendBlogs',
          component: () => import('../views/frontend/blog/ListView.vue')
        }
      ]
    },
    // 登录页
    {
      path: '/login',
      name: 'Login',
      component: () => import('../views/login/Layout_View.vue')
      // children: [
      //   {
      //     path: 'blogs',
      //     name: 'Blogs',
      //     component: () => import('../views/frontend/blog/ListView.vue')
      //   }
      // ]
    },
    // 后台(顶部导航/侧边栏导航/内容区)
    {
      path: '/backend',
      name: 'Backend',
      component: () => import('../views/backend/Layout_View.vue'),
      // redirect: {name: 'BackendBlogs'},
      children: [
        {
          path: 'blogs',
          name: 'BackendBlogs',
          component: () => import('../views/backend/blog/ListView.vue')
        },
        {
          path: 'blogs_edit',
          name: 'EditBlogs',
          component: () => import('../views/backend/blog/EditView.vue')
        },
        {
          path: 'comments',
          name: 'CommentList',
          component: () => import('../views/backend/comment/ListPage.vue')
        }
      ]
    }
  ]
})


router.beforeEach(beforeEach)
export default router
